package com.example.i.spy;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class InitiatorInput extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
		this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        setContentView(R.layout.activity_initiator_input);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_initiator_input, menu);
        return true;
    }
    
    public void okClick(View view)
    {
    	Intent i = new Intent();
    	
    	EditText editObjectName = (EditText) findViewById(R.id.edit_object_name);
    	String message = editObjectName.getText().toString();
    	
    	EditText editHint = (EditText) findViewById(R.id.edit_hint);
    	String message2 = editHint.getText().toString();
    	
    	if(!message.equals("") && !message2.equals(""))
    	{
	    	i.putExtra("objectName", message);
	    	i.putExtra("hint", message2);
	    	
	    	setResult(RESULT_OK, i);
	    	finish();
    	}
    	else
    	{
			// show the losing dialog
			Context context = getApplicationContext();
			CharSequence text = "Fill out the information above please!";
			int duration = Toast.LENGTH_SHORT;
			Toast toast = Toast.makeText(context, text, duration);
			toast.show();
    	}
    }
}
